import urllib
 
#optionsUrl = "http://finance.yahoo.com/q/op?s=AAPL+Options"
 
optionsUrl = "http://finance.yahoo.com/q/op?s=C+Options" 
optionsUrl = "http://finance.yahoo.com/q/op?s=C&m=2012-10"

pages = ['http://finance.yahoo.com/q/op?s=C&m=2012-11','http://finance.yahoo.com/q/op?s=C&m=2012-10']
optionsPage = urllib.urlopen(optionsUrl)
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(optionsPage)

pages = ['C120922C00033000','C121020P00023000']
#soup.findAll( text="C120824C00031000")
#soup.findAll( text="C120818C00028000")[0].parent
#soup.findAll( text="C120818C00028000")[0].parent.parent
#soup.findAll( text="C120824C00031000")[0].parent.parent

#for y in soup.findAll('td', attrs={"class" : "yfnc_h", "nowrap" : "nowrap"}):
#    print y


#"class" : "yfnc_tabledata1" ,


optionsTable = [[x.text for x in y.parent.contents] for y in soup.findAll('td', attrs={"class" : "yfnc_tabledata1", "nowrap" : "nowrap"})]
optionsTable2 =[[x.text for x in y.parent.contents] for y in soup.findAll('td', attrs={"class" : "yfnc_h", "nowrap" : "nowrap"})]

#optionsTable = [[x.text for x in y.parent.contents] for y in soup.findAll('td', attrs={"class" : "yfnc_h", "nowrap" : "nowrap"})]
optionsTable.extend(optionsTable2)

for row in optionsTable:
    for d in row:
        print d